home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
vb_term2
/
tty.frm
< prev
next >
Wrap
Text File
|
1995-09-06
|
5KB
|
232 lines
VERSION 2.00
Begin Form TTY
BackColor = &H00FFFFFF&
BorderStyle = 0 'None
Caption = "Terminal"
ClientHeight = 405
ClientLeft = 1050
ClientTop = 2160
ClientWidth = 4365
FontBold = 0 'False
FontItalic = 0 'False
FontName = "Courier"
FontSize = 9.75
FontStrikethru = 0 'False
FontTransparent = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 1095
Icon = TTY.FRX:0000
Left = 990
LinkMode = 1 'Source
LinkTopic = "Form1"
ScaleHeight = 27
ScaleMode = 3 'Pixel
ScaleWidth = 291
Top = 1530
Width = 4485
Begin Menu file
Caption = "&File"
Begin Menu mcexit
Caption = "&Exit"
Shortcut = ^X
End
End
Begin Menu settings
Caption = "&Settings"
Begin Menu comparams
Caption = "&Com Params"
End
End
Begin Menu transfers
Caption = "&Transfers"
Begin Menu capture
Caption = "&Capture to file ..."
Shortcut = ^C
End
End
End
Sub capture_Click ()
If (FlagCapture = 0) Then
opencapture.Show 1
Else
Close #FlagCapture
FlagCapture = 0
capture.caption = "Capture to file ..."
End If
End Sub
Sub CloseCom ()
Dim x As Integer
x = SerialClose()
If (x < 0) Then
MsgBox "Close Error"
Else
MsgBox "Closed"
End If
End Sub
Sub comparams_Click ()
Call ConfigCom
End Sub
Sub ConfigCom ()
Call hide_cursor
mousepointer = 11
TConfigChanged = 0
config.Show 1
x% = DoEvents() ' Force Screen Update
If (TConfigChanged <> 0) Then
x% = SerialClose()
x% = SerialOpen(TPort)
x% = SerialConfig(TBaud, TWord, TParity)
End If
mousepointer = 0
Call disp_cursor
End Sub
Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
'------------------------------------------------------------------------
' Form_KeyDown
'
' intercepts keys which do not generate an ANSI code, such as the
' function and cursor movement keys, and translates them into VT100
' style kepresses which are transmitted to the Form_Keypress()
' event, which deals with transmitting keystrokes. It could
' alternatively transmit keystrokes directly.
'------------------------------------------------------------------------
buf$ = ""
Select Case KeyCode
Case KEY_LEFT
buf$ = "[D"
' Case KEY_END
' buf$ = ""
Case KEY_HOME
buf$ = "[H"
Case KEY_UP
buf$ = "[A"
Case KEY_RIGHT
buf$ = "[C"
Case KEY_DOWN
buf$ = "[B"
' Case KEY_INSERT
' buf$ = ""
' Case KEY_DELETE
' buf$ = ""
Case Else
Exit Sub
End Select
buf$ = Chr$(27) + buf$
r% = SerialWrite(buf$)
End Sub
Sub form_KeyPress (KeyAscii As Integer)
r% = SerialWrite(Chr$(KeyAscii))
End Sub
Sub Form_Load ()
mousepointer = 11
tty.scalemode = 1
tty.height = (tty.height - tty.scaleheight) + 24.25 * tty.TextHeight("M")
tty.width = (tty.width - tty.scalewidth) + 80 * tty.TextWidth("M")
tty.top = 0
tty.left = (screen.width - tty.width) / 2
tty.scalemode = 3
tty.Show
Call term_init
config.Show 1
r% = SerialOpen(TPort)
If (r% <> 0) Then
MsgBox "Unable to open port", 16, "VBTERM"
End
End If
r% = SerialConfig(TBaud, TWord, TParity)
If (r% <> 0) Then
MsgBox "Unable to configure port", 16, "VBTERM"
End
End If
FlagCapture = 0
mousepointer = 0
Call ReceiveLoop
End Sub
Sub Form_Paint ()
Call RedrawScreen
End Sub
Sub Form_Unload (Cancel As Integer)
i% = SerialClose()
If (FlagCapture <> 0) Then Close #FlagCapture
End
End Sub
Sub mcexit_Click ()
Form_Unload (i%)
End Sub
Sub ReceiveLoop ()
Dim b As String
Dim ln As Integer
b = Space$(128)
ComPollLoop:
ln = SerialRead(b, 128)
If ln <> 0 Then
Call term_put(b, ln)
If (FlagCapture <> 0) Then Print #FlagCapture, Left$(b, ln);
Else
Call disp_cursor
End If
x% = DoEvents()
GoTo ComPollLoop
End Sub